import type { APIRoute } from 'astro' import { createJsonResponse, createIndexKey } from '../../../utils/apiHelpers' import { fetchApiIndex } from '../../../utils/apiIndex/fetch' export const prerender = false export const GET: APIRoute = async ({ params, url }) => { const { version, section } = params if (!version || !section) { return createJsonResponse( { error: 'Version and section parameters are required' }, 400, ) } try { const index = await fetchApiIndex(url) // Get pages for this section (includes underscore-separated subsection pages like "forms_checkbox") const key = createIndexKey(version, section) const pages = index.pages[key] if (!pages) { return createJsonResponse( { error: `Section '${section}' not found for version '${version}'` }, 404, ) } // Return pages array (already sorted, contains both regular and underscore-separated subsection pages) return createJsonResponse(pages) } catch (error) { const details = error instanceof Error ? error.message : String(error) return createJsonResponse( { error: 'Failed to load API index', details }, 500 ) } }